﻿using System.Data;
using System.Net;
using System.Net.Http.Headers;
using System.Security.Cryptography;
using System.Text;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
using OfficeOpenXml;
using Simple.Services;
using Simple.Services.System;
using Simple.Services.System.QHSEDanger.Models.AnalysisInput;
using Simple.Services.System.QHSEXyViolation.Models;

namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 违章管理
/// </summary>
[Route("QHSEXyViolation/[action]")]
[ApiController]
public class QHSEXyViolationController : ControllerBase
{
    private readonly QHSEXyViolationService _violationService;
    private readonly QHSEExcelService _excelService;
    
    public QHSEXyViolationController(QHSEXyViolationService violationService, QHSEExcelService excelService)
    {
        _violationService = violationService;
        _excelService = excelService;
    }
    //[HttpPost]
    //[ValidateTimestampAndSignature]
    //public async Task<AppResult> GetBySql([FromBody] IdInputModel model)
    //{
    //    List<QHSEXyViolationModel> data = await _violationService.GetBySqlAsync(model);
    //    return AppResult.Status200OK(data: data);
    //}
    /// <summary>
    /// 违章列表
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_v_all_list")]
    public async Task<AppResult> List()
    {
        List<QHSEXyViolationModel> data = await _violationService.GetAsync();
        return AppResult.Status200OK(data: data);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> List1()
    {
        List<QHSEXyViolationModel> data = await _violationService.GetAsync();
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 数据推送
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("company_violation_send")]
    public AppResult Push([FromBody] DangerMsg model)
    {
        utilService.PushDanger(model);
        return AppResult.Status200OK();
    }
    /// <summary>
    /// 违章查询
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_v_all_page")]
    public async Task<AppResult> Page([FromQuery] ViolationPageInputModel model)
    {
        PageResultModel<QHSEXyViolationModel> data = await _violationService.GetPageAsync(model);
        return AppResult.Status200OK(data: data);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> Page1([FromQuery] ViolationPageInputModel model)
    {
        PageResultModel<QHSEXyViolationModel> data = await _violationService.GetPageAsync(model);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 新增违章
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_all_insert")]
    public async Task<AppResult> Add([FromBody] QHSEXyViolationModel model)
    {
        var i = await _violationService.AddAsync(model);
        return AppResult.Status200OK(data:i);
    }
    /// <summary>
    /// 批量新增隐患
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_all_insert")]
    public async Task<AppResult> AddBatch([FromBody] List<QHSEXyViolationModel> model)
    {
        var i = await _violationService.AddBatchAsync(model);
        AppResult result = new AppResult();
        int count = 0;
        List<string> ids = new List<string>();
        foreach (var k in i)
        {
            if (k.models != null && k.res == "请完善信息")
            {
                result.ResData.Add(k.models);
                count++;
            }
            else
            {
                ids.Add(k.res);
            }
        }
        result.Data = "提交成功数：" + (i.Count() - count).ToString() +"--------id:" + ids;
        return result;
    }
    [HttpPost]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> Add1([FromBody] QHSEXyViolationModel model)
    {
        var i = await _violationService.Add1Async(model);
        if (i == "请完善信息")
        {
            return AppResult.Status500InternalServerError(data: i);
        }
        return AppResult.Status200OK(data: i);
    }
    /// <summary>
    /// 违章编辑
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_all_edit")]
    public async Task<AppResult> Edit([FromBody]QHSEXyViolationModel model)
    {
        await _violationService.UpdateAsync(model);
        return AppResult.Status200OK("更新成功");
    }
    /// <summary>
    /// 违章编辑
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_all_edit")]
    public async Task<AppResult> EditManagement([FromBody] QHSEXyViolationManagementModel model)
    {
        await _violationService.UpdateManagementAsync(model);
        return AppResult.Status200OK("更新成功");
    }
    [HttpPost]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> Edit1([FromBody] QHSEXyViolationModel model)
    {
        await _violationService.UpdateAsync(model);
        return AppResult.Status200OK("更新成功");
    }

    /// <summary>
    /// 违章删除
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    [HttpDelete]
    [CustomAuthorize("hdv_qhse_v_all_delete")]
    public async Task<AppResult> Delete([FromBody] List<IdInputModel> model)
    {
        await _violationService.DeleteAsync(model.Select(m => m.Id));
        return AppResult.Status200OK("删除成功");
    }
    [HttpDelete]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> Delete1([FromBody] List<IdInputModel> model)
    {
        await _violationService.DeleteAsync(model.Select(m => m.Id));
        return AppResult.Status200OK("删除成功");
    }
    /// <summary>
    /// 违章详情
    /// </summary>
    /// <param name="inputID"></param>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_all_querydetail")]
    public async Task<AppResult> QueryDetail([FromBody]IdInputModel inputID)
    {
        var data = await _violationService.QueryDetailAsyncSQL(inputID.Id);
        return AppResult.Status200OK(data:data);
    }
    [HttpPost]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> QueryDetail1([FromBody] IdInputModel inputID)
    {
        var data = await _violationService.QueryDetailAsync(inputID.Id);
        return AppResult.Status200OK(data: data);
    }
    [HttpPost]
    public async Task<AppResult> QueryDetailCache([FromBody] IdInputModel inputID)
    {
        var data = await _violationService.QueryDetailCacheAsync(inputID.Id);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 综合违章查询
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_compage")]
    public async Task<AppResult> ComPage([FromBody] ComViolationPageInputModel model)
    {
        PageResultModel<QHSEXyViolationModel> data = await _violationService.GetComPageAsync(model);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 员工全职业生涯
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_compage")]
    public async Task<AppResult> ComPageUser([FromBody] ComViolationUserPageInputModel model)
    {
        PageResultModel<QHSEXyViolationModel> data = await _violationService.GetComPageUserAsync(model);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 员工全职业生涯导出
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_compage")]
    public async Task<IActionResult> DownloadExcelUser([FromBody] ComViolationUserPageInputModel model)
    {
        var fileBytes = await _violationService.UploadExcelUser(model);
        var fileName = "violation_" + DateTime.Now + ".xlsx";
        var contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

        return File(fileBytes, contentType, fileName);
    }
    [HttpPost]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> ComPage1([FromBody] ComViolationPageInputModel model)
    {
        PageResultModel<QHSEXyViolationModel> data = await _violationService.GetComPageAsync(model);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 文件导出
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_compage")]
    public async Task<IActionResult> DownloadExcel([FromBody] ComViolationPageInputModel model)
    {
        var fileBytes = await _violationService.UploadExcel(model);
        var fileName = "violation_"+DateTime.Now+".xlsx";
        var contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

        return File(fileBytes, contentType, fileName);
    }
    /// <summary>
    /// 作业专业分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> WorkSpecialtyAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationService.WorkSpecialtyAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章原因分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> ViolationCauseAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationService.ViolationCauseAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 归属直线部门分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> DirectDepartmentAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationService.DirectDepartmentAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 体系要素分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> HseElementAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationService.HseElementAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 通用/专业分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> ViolationTypeCategoryAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationService.ViolationTypeCategoryAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章性质分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> ViolationTypeAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationService.ViolationTypeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章总体分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> DangerTrendAnalysis([FromBody] ViolationTrendInput input)
    {
        var res = await _violationService.ViolationTrendAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章总体分析--二级单位
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> SecondaryUnitAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationService.SecondaryUnitAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--违章趋势
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationSpecialityAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var res = await _violationService.ViolationSpecialtyAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--关键作业
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationKeyWorkTypeAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var res = await _violationService.ViolationKeyWorkTypeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--违章性质
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationViolationTypeAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var res = await _violationService.ViolationViolationTypeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--通用/专业
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationViolationTypeCateGoryAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var res = await _violationService.ViolationViolationTypeCategoryAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--违章岗位
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationPostionAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var res = await _violationService.ViolationPositionAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--违章区域
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationLocationAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var res = await _violationService.ViolationLocationAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--违章原因
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationViolationCauseAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var res = await _violationService.ViolationViolationCauseAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--归属直线部门
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationDirectDepartmentAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var res = await _violationService.ViolationDirectDepartmentAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--体系要素
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationHSEElementAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var res = await _violationService.ViolationHSEElementAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--工龄
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationWorkYearsAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var res = await _violationService.ViolationWorkYearsAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--年龄
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationAgeAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var res = await _violationService.ViolationAgeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--用工性质
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationEmployeeTypenAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var res = await _violationService.ViolatioEmployeeTypeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章专业分析--违章类别
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zy_analysis")]
    public async Task<AppResult> ViolationSpecialtyCategoryAnalysis([FromBody] ViolationSpecialityInput input)
    {
        var speciality = new List<string>();
        speciality.Add(input.WorkSpeciality);
        ViolationSpecialtyAnalysisInput input1 = new ViolationSpecialtyAnalysisInput
        {
            CheckType = input.CheckType,
            OrganizationName = input.OrganizationName,
            OrganizationId = input.OrganizationId,
            TimeOn = input.TimeOn,
            TimeEnd = input.TimeEnd,
            WorkSpeciality = speciality,
            ViolationCategory = "不安全因素",
            CheckOrganizationId = input.CheckOrganizationId
        };
        var res = await _violationService.ViolationSpecialtyCategoryAnalysisAsync(input1);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章人员工龄分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> WorkYearAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationService.WorkYearAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章人员年龄分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> AgeAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationService.AgeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章人员用工性质分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> EmployeeTypeAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationService.EmployeeTypeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章类别分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> ViolationCategoryAnalysis([FromBody] ViolationCategoryInput input)
    {
        var res = await _violationService.ViolationCategoryAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 不安全因素分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> BAQYSAnalysis([FromBody] ViolationAnalysisInput input)
    {
        ViolationCategoryInput input1 = new ViolationCategoryInput
        {
            OrganizationName = input.OrganizationName,
            OrganizationId = input.OrganizationId,
            TimeOn = input.TimeOn,
            TimeEnd = input.TimeEnd,
            CheckType = input.CheckType,
            ViolationCategory = "不安全因素",
            CheckOrganizationId = input.CheckOrganizationId
        };
        var res = await _violationService.ViolationCategoryAnalysisAsync(input1);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 人的不安全行为分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> RDBAQXWAnalysis([FromBody] ViolationAnalysisInput input)
    {
        ViolationCategoryInput input1 = new ViolationCategoryInput
        {
            OrganizationName = input.OrganizationName,
            TimeOn = input.TimeOn,
            TimeEnd = input.TimeEnd,
            CheckType = input.CheckType,
            ViolationCategory = "违章操作"
        };
        var res = await _violationService.ViolationCategoryAnalysisAsync(input1);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 管理缺陷分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> QXGLAnalysis([FromBody] ViolationAnalysisInput input)
    {
        ViolationCategoryInput input1 = new ViolationCategoryInput
        {
            OrganizationName = input.OrganizationName,
            TimeOn = input.TimeOn,
            TimeEnd = input.TimeEnd,
            CheckType = input.CheckType,
            ViolationCategory = "违章指挥"
        };
        var res = await _violationService.ViolationCategoryAnalysisAsync(input1);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违反劳动纪律分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> WFLDJLAnalysis([FromBody] ViolationAnalysisInput input)
    {
        ViolationCategoryInput input1 = new ViolationCategoryInput
        {
            OrganizationName = input.OrganizationName,
            TimeOn = input.TimeOn,
            TimeEnd = input.TimeEnd,
            CheckType = input.CheckType,
            ViolationCategory = "违反劳动纪律"
        };
        var res = await _violationService.ViolationCategoryAnalysisAsync(input1);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 作业安全管理缺陷分析
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_zt_analysis")]
    public async Task<AppResult> ZYAQGLQXAnalysis([FromBody] ViolationAnalysisInput input)
    {
        ViolationCategoryInput input1 = new ViolationCategoryInput
        {
            OrganizationName = input.OrganizationName,
            TimeOn = input.TimeOn,
            TimeEnd = input.TimeEnd,
            CheckType = input.CheckType,
            ViolationCategory = "作业安全管理缺陷"
        };
        var res = await _violationService.ViolationCategoryAnalysisAsync(input1);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 查人
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> ClausResult([FromBody] IdInputModel idInput)
    {
        var data = await _violationService.GetUserAsync(idInput);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 图片对比
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> ComparePic([FromBody] FileUploadItem model)
    {
        var data = await _violationService.IsImageDuplicate(model.Base64Content);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 违章重复性
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_cfxwz")]
    public async Task<IActionResult> ViolationAdministerRepeat([FromBody] QHSEViolationAdministerRepeatInputModel model)
    {
        var data = await _violationService.ViolationAdministerRepeatAsync(model);
        return Ok(JsonConvert.SerializeObject(data));
    }
    /// <summary>
    /// 数据统计
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_totalQuery_violation")]
    public async Task<AppResult> ViolationTotalQuery([FromBody] ViolationTotalInputModel model)
    {
        var data = await _violationService.ViolationTotalQueryAsync(model);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 数据导入
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_compage")]
    public async Task<AppResult> ViolationSelectUpload([FromBody] QHSEViolationUploadModel model)
    {
        var data = await _excelService.ImportViolationExcel(model);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 判断是否重复
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> GetViolationRepeat([FromBody] QHSEViolationRepeatModel model)
    {
        var data = await _violationService.GetRepeatAsync(model);
        return AppResult.Status200OK(data: data);
    }
}

